function [] = search_error()
global des_flag
global xd_estimate yd_estimate
global delta_t Tsum
global xdyd
global N N2

tspan=0:delta_t:Tsum;
m0=length(tspan);
for i=1:m0-1
    tk(i) = i*delta_t;  %时间刻度
end

color=['b','r',	'm','g','k'];
%disp(m0)
% disp(size(xdyd,1))

for number=1:N
    if sum( sum( des_flag(number ,:, :) ) ) ~=0
        figure;
        for i=2:m0-2
            for k=1:size(xdyd,1)
                for j=1:N2-2
                    if des_flag(number ,k, i) == 1 && des_flag(number ,k, i+10) == 1
                        d_x = xd_estimate(number ,k ,j , i ) - xdyd(k, 1) ;
                        d_y = yd_estimate(number ,k ,j , i ) - xdyd(k, 2);
                        d_x10 = xd_estimate(number ,k ,j , i+10 ) - xdyd(k, 1) ;
                        d_y10 = yd_estimate(number ,k ,j , i+10 ) - xdyd(k, 2);
                        hold on
                        plot( [tk(i), tk(i+10)], ...
                            [...
                            norm( [d_x, d_y] ), ...
                            norm( [d_x10, d_y10] ) ]...
                            , [color(j), ':'])                    
                    end
                end
                if des_flag(number ,k, i) == 1 && des_flag(number ,k, i+10) == 1
                    d_x_mean = mean(xd_estimate(number, k, : , i) ) - xdyd(k,1) ;
                    d_y_mean = mean(yd_estimate(number, k, : , i) ) - xdyd(k,2) ;
                    d_x_mean10 = mean(xd_estimate(number, k, : , i+10) ) - xdyd(k,1) ;
                    d_y_mean10 = mean(yd_estimate(number, k, : , i+10) ) - xdyd(k,2) ; 
                    hold on;
                    plot( [tk(i), tk(i+10)], [ norm( [d_x_mean, d_y_mean] ), norm( [d_x_mean10, d_y_mean10] ) ], 'r')
                end
            end
        end
        axis([0,Tsum, 0, inf ])
        grid on
        legend('UAV1-error', 'UAV2-error', 'UAV3-error', 'UAV4-error', 'fusion-error')
        xlabel('time(s)')
        ylabel('detect error(m^2)')
        title( ['The detect error of group',num2str(number)] )
    end
end


        
